﻿<UserControl
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
			 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
			 xmlns:command="http://www.galasoft.ch/mvvmlight"
			 xmlns:Converters="clr-namespace:UIExample.Converters"
			 xmlns:behavior="clr-namespace:UIExample.Behavior"
			 xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
			 x:Class="UIExample.View.UMPView"
			 mc:Ignorable="d"  
			 HorizontalAlignment="Left" VerticalAlignment="Top" Width="566.627">
    <UserControl.Resources>
        <Converters:FilterToVisiabilityConverter x:Key="FilterToVisiabilityConverter"/>
    </UserControl.Resources>
    <UserControl.Visibility>
        <Binding Converter="{StaticResource BooleanToVisibilityConverter}" Mode="OneWay" Path="Visual"/>
    </UserControl.Visibility>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseMove">
            <command:EventToCommand Command="{Binding Main.Dragging, Mode=OneWay, Source={StaticResource Locator}}" PassEventArgsToCommand="True"></command:EventToCommand>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <i:Interaction.Behaviors>
        <behavior:DragBehavior>
        </behavior:DragBehavior>
    </i:Interaction.Behaviors>
    <Grid DataContext="{Binding }" Height="262"  >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="195"/>
            <ColumnDefinition Width="152"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Rectangle Margin="0,94,0,65"  Stroke="Black"  Grid.Column="1">
            <Rectangle.Fill>
                <SolidColorBrush Color="#FFF4F4F5" Opacity="0.9"/>
            </Rectangle.Fill>
        </Rectangle>
        <ed:LineArrow   Stroke="Black" ArrowSize="10" HorizontalAlignment="Left" Height="66" Margin="32,28,0,0" 
			VerticalAlignment="Top" Width="1" RenderTransformOrigin="0.5,0.5"  Cursor="Hand" IsEnabled="False" 
			Fill="Black" OpacityMask="Black" Grid.Column="1"/>
        <ed:LineArrow   Stroke="Black" ArrowSize="10" HorizontalAlignment="Left" Height="59" Margin="32,198,0,0" 
			VerticalAlignment="Top" Width="1" RenderTransformOrigin="0.5,0.5"  Cursor="Hand" IsEnabled="False" 
			Fill="Black" OpacityMask="Black" Grid.Column="1">
            <ed:LineArrow.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleY="-1"/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </ed:LineArrow.RenderTransform>
        </ed:LineArrow>
        <ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="0,94,0,0" VerticalScrollBarVisibility="Auto" Grid.Column="0">

            <StackPanel Background="Transparent" HorizontalAlignment="Stretch"  >
                <ItemsControl ItemsSource="{Binding Inputs}" >
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <DockPanel >
                                <Grid  DockPanel.Dock="Left"  AllowDrop="True"   Background="Transparent" Height="40" Cursor="Hand" HorizontalAlignment="Stretch"  VerticalAlignment="Top"  >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="10"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.Visibility>
                                        <MultiBinding Converter="{StaticResource FilterToVisiabilityConverter}">
                                            <Binding Path="Main.InFilter" Mode="OneWay"  Source="{StaticResource Locator}"/>
                                            <Binding Path="DataContext" RelativeSource="{RelativeSource Mode=Self}"/>
                                        </MultiBinding>

                                    </Grid.Visibility>
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="MouseLeftButtonDown" >
                                            <command:EventToCommand Command="{Binding Main.SetFilterStartDragDrop, Mode=OneWay, Source={StaticResource Locator}}"  PassEventArgsToCommand="true" />
                                        </i:EventTrigger>

                                        <i:EventTrigger EventName="Drop" >
                                            <command:EventToCommand Command="{Binding Main.Link, Mode=OneWay, Source={StaticResource Locator}}"  PassEventArgsToCommand="true" />
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="MouseEnter">
                                            <command:EventToCommand Command="{Binding Main.MouseOn, Mode=OneWay, Source={StaticResource Locator}}" PassEventArgsToCommand="True" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                    <ed:LineArrow  Grid.Row="0" Margin="0,7,0,0"  OpacityMask="Black" Stroke="Black" ArrowSize="10" Height="0"  HorizontalAlignment="Stretch"    VerticalAlignment="Top" Stretch="Fill"  Cursor="Hand" IsEnabled="False" Fill="Black" />
                                    <Viewbox VerticalAlignment="Top" HorizontalAlignment="Right"  Grid.Row="1" Width="110" >
                                        <TextBlock ToolTip="{Binding ShowName}"  FontSize="12"  TextWrapping="WrapWithOverflow" Text="{Binding ShowName}"/>
                                    </Viewbox>
                                </Grid>
                                <xctk:DecimalUpDown  DockPanel.Dock="Right" IsEnabled="{Binding Independent}" Value="{Binding DependentValue}" >

                                </xctk:DecimalUpDown>
                            </DockPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </ScrollViewer>
        <ScrollViewer  Grid.Column="2" Margin="0,94,0,0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <StackPanel Background="Transparent" HorizontalAlignment="Stretch">
                <ItemsControl ItemsSource="{Binding Outputs}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <DockPanel  >
                                <Grid  DockPanel.Dock="Right" AllowDrop="True"  Height="40" Cursor="Hand" HorizontalAlignment="Left"  VerticalAlignment="Top" Width="130" >
                                    <Grid.Visibility>
                                        <MultiBinding Converter="{StaticResource FilterToVisiabilityConverter}" UpdateSourceTrigger="PropertyChanged">
                                            <Binding Path="Main.OutFilter" Mode="OneWay"  Source="{StaticResource Locator}"/>
                                            <Binding Path="DataContext" RelativeSource="{RelativeSource Mode=Self}"/>
                                        </MultiBinding>

                                    </Grid.Visibility>
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Drop" >
                                            <command:EventToCommand Command="{Binding Main.Link, Mode=OneWay, Source={StaticResource Locator}}"  PassEventArgsToCommand="true" />
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="MouseLeftButtonDown" >
                                            <command:EventToCommand Command="{Binding Main.SetFilterStartDragDrop, Mode=OneWay, Source={StaticResource Locator}}"  PassEventArgsToCommand="True" />
                                        </i:EventTrigger>


                                        <i:EventTrigger EventName="MouseEnter">
                                            <command:EventToCommand Command="{Binding Main.MouseOn, Mode=OneWay, Source={StaticResource Locator}}" PassEventArgsToCommand="True" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="10"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <ed:LineArrow Grid.Row="0" OpacityMask="Black" Stroke="Black" ArrowSize="10" Height="0" Margin="0,7,6,0" HorizontalAlignment="Stretch"    VerticalAlignment="Top"  Width="Auto"  Cursor="Hand" IsEnabled="False" Fill="Black" />
                                    <Viewbox VerticalAlignment="Top" HorizontalAlignment="Right"  Grid.Row="1" Width="125" >
                                        <TextBlock ToolTip="{Binding ShowName}" TextWrapping="WrapWithOverflow" Text="{Binding ShowName}"/>
                                    </Viewbox>
                                </Grid>
                                <xctk:DecimalUpDown  DockPanel.Dock="Left" IsEnabled="{Binding Independent}" Value="{Binding DependentValue}" >

                                </xctk:DecimalUpDown>
                            </DockPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </ScrollViewer>
        <Viewbox ToolTip="{Binding Equations}" Margin="5,120,5,0" Height="43" Grid.Column="1" VerticalAlignment="Top">
            <TextBlock  TextWrapping="Wrap" Text="{Binding UMP.name}"    TextAlignment="Center"/>
        </Viewbox>
        <Viewbox  Margin="38,28,0,0" Height="61" Grid.Column="1" VerticalAlignment="Top">
            <TextBlock  TextWrapping="WrapWithOverflow" Text="{Binding ProcessInformation}" />
        </Viewbox>

    </Grid>
</UserControl>
